package com.gitee.wsl.transform.format

import com.gitee.wsl.ext.base.CharExt


/**
 * @author light
 * @since 2023/4/12
 */

interface HowIntRangeToString {
    fun infiniteToString(): String
    fun negativeInfiniteToString(): String
    fun positiveInfiniteToString(): String

    fun intToString(i: Int): String
}

/**
 * [IntRange.toString] 默认显示数字, 而此 toString 策略将 Unicode 数字转为对应字符
 */
val UNICODE_INT_RANGE_TO_STRING = object : HowIntRangeToString {
    override fun infiniteToString(): String {
        return "Any"
    }

    override fun negativeInfiniteToString(): String {
        return "∞"
    }

    override fun positiveInfiniteToString(): String {
        return "∞"
    }

    override fun intToString(i: Int): String {
        return CharExt.toUnicodeString(i)
    }
}


val DEFAULT_INT_RANGE_TO_STRING = object : HowIntRangeToString {
    override fun infiniteToString(): String {
        return "∞"
    }

    override fun negativeInfiniteToString(): String {
        return "∞"
    }

    override fun positiveInfiniteToString(): String {
        return "∞"
    }

    override fun intToString(i: Int): String {
        return i.toString()
    }
}

